import { request } from '@/utils/request'
import { Login, Request } from '../interface/index'

// 封装User类型的接口方法
export class UserService {
  /**
   *
   * @returns 返回登录信息
   */
  static async getLoginInfo(): Promise<Login.ILoginInfo> {
    return request<Login.ILoginInfo>({
      method: 'get',
      url: '/login/info',
    })
  }

  /**
   * @description 查询User的信息
   * @param {number} teamId - 所要查询的团队ID
   * @return {HttpResponse} result
   */
  static async login(
    params: Login.ReqLoginForm,
  ): Promise<Request.HttpResponse> {
    return request<Request.HttpResponse>({
      method: 'get',
      responseType: 'json',
      url: '/api/user/getUserInfo',
      params: {
        ...params,
      },
    })
  }

  static async register(
    params: Login.ReqLoginForm,
  ): Promise<Request.HttpResponse> {
    return request<Request.HttpResponse>({
      method: 'get',
      responseType: 'json',
      url: '/api/user/register',
      params: {
        ...params,
      },
    })
  }
}
